package com.njym.java.security.admin.rest;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.njym.java.security.admin.biz.InvesttblBiz;
import com.njym.java.security.admin.entity.InvestGroup;
import com.njym.java.security.admin.entity.Investtbl;
import com.njym.java.security.common.msg.ObjectRestResponse;
import com.njym.java.security.common.msg.TableResultResponse;
import com.njym.java.security.common.rest.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import tk.mybatis.mapper.entity.Example;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("investtbl")
public class InvesttblController extends BaseController<InvesttblBiz, Investtbl> {

    /**
     * 问卷信息
     * @param limit
     * @param page
     * @param name
     * @param typetblId
     * @return
     */
    @RequestMapping(value = "/getListByParams",method = RequestMethod.GET)
    @ResponseBody
    public ObjectRestResponse<Investtbl> getListByParams(
            @RequestParam(defaultValue = "10") int limit,
            @RequestParam(defaultValue = "1")int page ,
            String name, Integer typetblId) {
        List<Investtbl> list = baseBiz.selectByExample(page,limit,name,typetblId);
        long total = PageInfo.of(list).getTotal();
        Map<String, Object> data = new HashMap<>(2);
        data.put("list", list);
        data.put("total", total);
        return new ObjectRestResponse<Investtbl>().rel(true).data(data);
    }

}